import { baseUrlApi, requestClient, type Result } from '#/api/request';

export interface UserActionsData {
  score?: number; // 奖励积分
  coin?: number; // 奖励金币
  cycle_time?: number; // 奖励周期数量
  cycle_type?: number; // 奖励周期类型;0:不限;1:天;2:小时;3:永久
  reward_number?: number; // 奖励次数
  id?: number; // id
}

/** 用户操作列表 */
export const getUserActions = () => {
  return requestClient.get<Result>(baseUrlApi('/admin/user/actions'));
};

/**
 * 获取用户操作信息
 * @param id
 * @returns
 */
export const getUserActionsInfo = (id: number) => {
  return requestClient.get<Result>(baseUrlApi(`/admin/user/actions/${id}`));
};

/**
 * 编辑用户操作
 * @param id
 * @param data
 * @returns
 */
export const putUserActions = (id: number, data?: UserActionsData) => {
  return requestClient.put<Result>(
    baseUrlApi(`/admin/user/actions/${id}`),
    data,
  );
};

/**
 * 同步用户操作
 * @returns
 */
export const postUserActionsSync = () => {
  return requestClient.post<Result>(baseUrlApi(`/admin/user/actions/sync`));
};
